home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group96a.txt / 000147_icon-group-sender _Sat Jun 29 10:41:11 1996.msg < prev    next >
Internet Message Format  |  1996-09-05  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 1 Jul 1996 08:32:45 MST
  2. Date: Sat, 29 Jun 1996 10:41:11 +0200
  3. From: karczma@calvin.info.unicaen.fr (Jerzy Karczmarczuk)
  4. Message-Id: <9606290841.AA03532@canardo.unicaen.fr>
  5. To: icon-group@cs.arizona.edu
  6. Subject: Re: Ordered tables
  7. X-Sun-Charset: US-ASCII
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9. Status: O
  10.  
  11.  
  12. > From: Hamish Lawson <H.Lawson@tees.ac.uk>
  13. > I'd like to be able to obtain the keys of a table in the order of their 
  14. > creation (key() produces them in random order). Is there a way to do 
  15. > this? Failing that, what is the best way to go about implementing a data 
  16. > structure in Icon that is both indexed and ordered?
  17. > | Hamish Lawson, School of Computing and Mathematics, 
  18.  
  19. Clinton Jeffery answered already. Hashed tables are popular for their
  20. efficiency, and overloading them with extra ordering info seems - in
  21. general - rather inefficient. So, Clint proposes a mirror list which keeps
  22. track of the creation time ordering. 
  23.  
  24. There is another possibility - store with each key not the bare item, but the
  25. pair [item, ord_index], eventually pair with the item a link to the predecessor/
  26. successor (or both) key(s). The memory overhead seems worse than in the proposal
  27. of CJ, but you can do it selectively. 
  28.  
  29. Jerzy Karczmarczuk
  30. Comp. Sci., University of Caen, France.
  31.